<?php	
	$path_one = 'admin/admin_project';
	$path_two = 'admin/car_set';
	$filename = 'admin/car_set';
	require_once("header.php");
	require_once("admin_comm.php");
	require_once $_site->get_handlepath('project');
		
	$admin_obj = new admin();
	$user_info = $admin_obj->out_cookie();
	if($user_info['id']==1){		
		$result=$admin_obj->search_customer("id,account,name");
		$pid=request('pid',false,true,false,0);
	}else{
		$pid=$user_info['id'];
	}	    
    
    if($pid){
    	$device_obj=new device();
    	$set_ary=$device_obj->setinfo_search($pid);    	
    	if($set_ary){    		
    		foreach($set_ary as $val){
    			$_ary[$val['type']][]=$val;    			
    		}
    	}
    }
?>
<script type="text/javascript" charset="utf-8">
	loader.file({
		plugin:['validform/main','dialog/main'],
		skincss:['list']
	})	
	
    //修改记录
	function editinfo(id,type){
		var title=(1==type)?'挖机编号设置':'运输线路设置';
		dialog.iframe({
			title:title,
			is_resize:false,
			top:{
				is_show:true,
				btn_max:false,
				btn_min:false,
				btn_close:true,
				height:33,
				is_move:true
			},
			is_scroll:false,
			min_width:500,
			min_height:400,
			is_center:true,
			is_lock_back:true,
			content:'/admin/car_edit?id='+id+'&type='+type+'&pid=<?php echo $pid;?>',
			name:'choise_project'
		});
	}	


	function del(id){
        if(!confirm('该操作不可撤销，是否删除？'))return false;
        $.getJSON("/handle.php?h=device/cardel&id="+id,function(res){
            if(res.state){
            	location.reload(true);
            	return;
            }
            alert(res.msg);
        })
    }

	
	function change(){
       location.reload(true);
	}
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?></div>
		<div class="main">

		<?php 
		 if($user_info['id']==1){
		?>
			<div class="sos_box">
				<form action="/admin/car_set" id="search" method='get'>
					<span>项目经理：</span>
				    <select name='pid'>
					   <option value="">请选择</option>
					      <?php 
					      if($result){
					      foreach($result as $key=>$val){
                          ?>
                             <option value="<?php echo $val['id']?>" <?php if($val['id']==$pid){echo "selected";} ?>><?php echo $val['name']?></option>
                          <?php 
                             }
                          }
					      ?>					 
					</select>						
					<input class="button1" type="submit" value="搜索">
				</form>
			</div>
			<?php 
			}
			?>
			
			<table cellpadding="0" cellspacing="1" border="0" class="table">
			    <?php 
			     if(empty($pid)){
			    ?>
				<tr>
					<td colspan="8">
						<div class="list_more">
							<font color="red">请选择相应项目项目经理！</font>
						</div>
					</td>
				</tr>
				<?php 
				 }
				?>						
			</table>
			
		    <?php 
		     if($pid){
		    ?>			
			<table cellpadding="0" cellspacing="1" border="0" class="table" style="margin-top: 20px;">	
			    <thead><tr><td colspan="6"><strong>挖机设置</strong><div style="float:right;margin-right:20px;"><a href="javascript:;" onclick="editinfo(0,1);">添加</a></div></td></tr></thead>			
	            <tr>
					<th align="center">序号</th>
					<th align="left">挖机编号</th>
					<th align="left">设备型号</th>
					<th align="center">状态</th>
					<th align="left">排序</th>
					<th align="center">操作</th>
				</tr>
				
				<?php 
				   if($_ary[1]){
                     $i=1;
                     foreach ($_ary[1] as $v){
				?>			
				<tr>
					<td align="center"><?php echo $i;$i++;?></td>
					<td align="left"><?php echo $v['code'];?></td>
					<td align="left"><?php echo $v['comment'];?></td>
					<td align="center"><?php echo 1==$v['state']?'开启':'<font color="red">关闭</font>' ;?></td>
					<td align="left"><?php echo $v['sort'];?></td>
					<td align="center"><a href="javascript:;" onclick="editinfo(<?php echo $v['id']?>,1);">修改</a>|<a href="javascript:;" onclick="del(<?php echo $v['id']?>)">删除</a></td>
				</tr>	
				<?php 
				  }
				}
				?>						
				
			</table>				
			
			
			<table cellpadding="0" cellspacing="1" border="0" class="table" style="margin-top: 20px;">			
			    <thead><tr><td colspan="6"><strong>线路设置</strong><div style="float:right;margin-right:20px;"><a href="javascript:;" onclick="editinfo(0,2);">添加</a></div></td></tr></thead>		
	            <tr>
					<th align="center">序号</th>
					<th align="left">线路编号</th>
					<th align="left">距离</th>
					<th align="center">状态</th>
					<th align="left">排序</th>
					<th align="center">操作</th>
				</tr>
				
				<?php 
				   if($_ary[2]){
                     $i=1;
                     foreach ($_ary[2] as $v){
				?>			
				<tr>
					<td align="center"><?php echo $i;$i++;?></td>
					<td align="left"><?php echo $v['code'];?></td>
					<td align="left"><?php echo $v['comment'];?></td>
					<td align="center"><?php echo 1==$v['state']?'开启':'<font color="red">关闭</font>' ;?></td>
					<td align="left"><?php echo $v['sort'];?></td>
					<td align="center"><a href="javascript:;" onclick="editinfo(<?php echo $v['id']?>,2);">修改</a>|<a href="javascript:;" onclick="del(<?php echo $v['id']?>)">删除</a></td>
				</tr>	
				<?php 
				  }
				}
				?>					
				
			</table>			
			<?php 
			}
			?>
			
		</div>
	</div>
</body>
</html>


